/**
 * 
 */
package com.edocbase.desktopserver;

import java.util.Map;

import com.edocbase.desktopserver.impl.IActionHandler;
import com.edocbase.desktopserver.impl.jetty.DesktopHttpResponse;

/**
 * @author lifei114@gmail.com
 *
 */
public abstract class WebActionHandler implements IActionHandler {
	protected IDesktopRequest request = null;
	protected DesktopHttpResponse response = null;
	/* (non-Javadoc)
	 * @see com.edocbase.desktopserver.impl.IActionHandler#setRequest(com.edocbase.desktopserver.DeskHttpRequest)
	 */
	@Override
	public void setRequest(IDesktopRequest request) {
		this.request = request;
	}
	public Map<String, String> getParameters() {
		return request.getParameters();
	}
	public String getParameter(String paramString) {
		return request.getParameter(paramString);
	}
	public void setAttribute(String paramString, Object paramObject) {
		request.setAttribute(paramString, paramObject);
	}
	public void removeAttribute(String paramString) {
		request.removeAttribute(paramString);
	}
	public Object getAttribute(String paramString) {
		return request.getAttribute(paramString);
	}
	public String getPath() {
		return request.getPath();
	}
	protected void assign(String name,Object value){
		setAttribute(name, value);
	}
	
	public DesktopHttpResponse getResponse() {
		return response;
	}
	public void setResponse(DesktopHttpResponse response) {
		this.response = response;
	}
	protected String display(String path){
		if (!path.endsWith(".ftl")){
			path = path.concat(".ftl");
		}
		
		return path;
	}
}
